<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue+ElementUI</title>
    <!-- import CSS -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="./style/index.css">
</head>
<body>
    <div id="app">
        <h1>通讯录</h1>
        <div class="head">
            <el-row :gutter="20">
                <el-col :span="6">
                    <el-input v-model="userInfo.name" placeholder="请输入姓名"></el-input>
                </el-col>
                <el-col :span="6">
                    <el-input v-model="userInfo.gender" placeholder="请输入性别"></el-input>
                </el-col>
                <el-col :span="6">
                    <el-date-picker v-model="userInfo.birthday" type="date" format="yyyy 年 MM 月 dd 日"  value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker>
                </el-col>
                <el-col :span="6">
                    <el-input v-model="userInfo.phoneNum" placeholder="请输入电话号码"></el-input>
                </el-col>
            </el-row>
            <el-button type="primary" @click="addUser" class="add-btn" plain>添加信息</el-button>
        </div>
        <div class="body">
            <template>
                <el-table :data="tableData" style="width: 100%">
                    <el-table-column label="序号" width="180"><template slot-scope="scope"> {{scope.$index + 1 }} </template></el-table-column>
                    <el-table-column prop="name" label="姓名" width="180"></el-table-column>
                    <el-table-column prop="gender" label="性别"></el-table-column>
                    <el-table-column prop="phoneNum" label="电话"></el-table-column>
                    <el-table-column prop="birthday" label="生日"></el-table-column>
                    <el-table-column prop="birthday" label="操作">
                        <template slot-scope="scope">
                            <el-button type="primary" icon="el-icon-edit" @click="editUser(scope.row,scope.$index)" circle></el-button>
                            <el-button type="danger" icon="el-icon-delete" @click="delUser(scope.$index)" circle></el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </template>
        </div>
        <el-dialog title="编辑用户信息" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
            <div>
                <el-form ref="form" :model="editObj" label-width="80px">
                    <el-form-item label="姓名"><el-input v-model="editObj.name"></el-input></el-form-item>
                    <el-form-item label="性别"><el-input v-model="editObj.gender"></el-input></el-form-item>
                    <el-form-item label="生日"><el-date-picker v-model="editObj.birthday" type="date" format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker></el-form-item>
                    <el-form-item label="电话号码"><el-input v-model="editObj.phoneNum"></el-input></el-form-item>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="confirm">确 定</el-button>
            </span>
        </el-dialog>
    </div>

    <!-- import Vue before Element -->
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <!-- import JavaScript -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="./javascript/index.js"></script>
</body>
</html>